package com.whfp.coky.ui.task.frag

import android.content.Context
import com.whfp.coky.databinding.FragFluorProjCloudBinding
import com.whfp.coky.databinding.ItemFluorProjCloudBinding
import com.whfp.coky.ui.base.BaseAdapter
import com.whfp.coky.ui.base.BaseRecycleFrag
import com.whfp.coky.ui.task.model.FluorProjCloudBean
import com.whfp.coky.ui.task.vm.fluor.FluorProjCloudFragVM
import com.whfp.coky.widget.clicks

/**
 *
 *
 * created by coky on 2022/3/16
 */
class FluorProjCloudFrag :BaseRecycleFrag<FluorProjCloudFragVM, FragFluorProjCloudBinding, FluorProjCloudBean>(){

    companion object{
        fun newInstance() = FluorProjCloudFrag()
    }

    override fun initView() {
        super.initView()
        vBinding.ibtnSearch.clicks {
            vModel.changeReq(vBinding.etSearch.getText().toString())
        }
    }

    override fun initAdapter(context: Context) = CloudAdapter(context)

    override fun initRecycler() = vBinding.recycler

    override fun initRefreshLayout() = vBinding.refreshLayout

    inner class CloudAdapter(mContext:Context): BaseAdapter<ItemFluorProjCloudBinding, FluorProjCloudBean>(mContext){
        override fun convert(v: ItemFluorProjCloudBinding, t: FluorProjCloudBean, position: Int) {
            v.tvProject.text = t.bqName
            v.tvProjectCode.text = t.bqBh
            v.tvWrite.clicks {
                toast("写入设备${t.bqName}")
            }
        }
    }

}